import complex_query from '@dfeidao/atom-nodejs/db/complex-query';
import { IncomingHttpHeaders } from 'http';
import { systemid } from '../../atom/config';

interface Message {
	exam_name: string;
	start_time: string;
	finish_time: string;
	examination_category: string;
	pnge_no: number;
	// cookie: {
	// 	uk: string;
	// 	[key: string]: string
	// };
	// urls: {
	// 	base: string;
	// 	origin: string;
	// 	url: string;
	// };
	// query: {};
	// params: {};
	// headers: {};
	// captcha: string;
}
// 考试管理exam_management>得到：

// "考试名称 exam_name"

// "考试类别 examination_category"

// "考试时长 exam_time"

// "试卷总分 exam_score "

// "开始时间 start_time"

// "结束时间 finish_time"
export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders) {
const query = complex_query(action_id,session_id,systemid);
const res = await query
.add_field('exam_management', 'exam_name', 'exam_name')
.add_field('exam_management', 'examination_category', 'examination_category')
.add_field('exam_management', 'exam_time', 'exam_time')
.add_field('exam_management', 'exam_score', 'exam_score')
.add_field('exam_management', 'start_time', 'start_time')
.add_field('exam_management', 'finish_time', 'finish_time')
.add_field('exam_management', 'exam_id', 'exam_id')
.where_like('exam_management','exam_name',"%" + message.exam_name + "%")
.where_like('exam_management','examination_category',"%" + message.examination_category + "%")
.where_gt('exam_management', 'start_time', message.start_time)
.where_lte('exam_management', 'finish_time', message.finish_time)
.page(20,message.pnge_no)
.exec();
const red = await query
.add_field('exam_management', 'exam_name', 'exam_name')
.add_field('exam_management', 'examination_category', 'examination_category')
.add_field('exam_management', 'exam_time', 'exam_time')
.add_field('exam_management', 'exam_score', 'exam_score')
.add_field('exam_management', 'start_time', 'start_time')
.add_field('exam_management', 'finish_time', 'finish_time')
.add_field('exam_management', 'exam_id', 'exam_id')
.where_like('exam_management','exam_name',"%" + message.exam_name + "%")
.where_like('exam_management','examination_category',"%" + message.examination_category + "%")
.where_gt('exam_management', 'start_time', message.start_time)
.where_lte('exam_management', 'finish_time', message.finish_time)
.exec();
return {res,red};
}
